<?php
/**
 * Created by 张彪.
 * User: 小马出行
 * Date: 2017/11/2
 * Time: 14:56
 */
namespace app\inter\model;

use \think\Model;
use think\Db;
class LocalModel extends Model
{

    public function addLocalAll($table,$data=array())
    {
        return Db::table($table)->insertAll($data);
    }

    public function localCount($table,$map)
    {
        return Db::table($table)->where($map)->count();
    }

    public function localOrderTrip($table,$map)
    {
        return Db::table($table)->where($map)->sum('distance');
    }
    public function getLocalTable($map=array(),$field='*',$flag=true,$order='id desc',$page=1,$limit=10)
    {
        return $flag ? Db::name('local_table')->where($map)->field($field)->page($page,$limit)->order($order)->select()
            :Db::name('local_table')->where($map)->field($field)->order($order)->find();
    }

    public function addLocalTable($data)
    {
        return Db::name('local_table')->insertGetId($data);
    }
}